<template>
	<page-meta :page-font-size="baseFontSize + 'rpx'" :root-font-size="baseFontSize + 'rpx'"></page-meta>
	<z-paging ref="paging" v-model="dataList" :auto-clean-list-when-reload="false" :auto-scroll-to-top-when-reload="false" :refresher-status.sync="refresherStatus" @query="loadList">
		<view class="list-item u-flex-y-center" v-for="(item, index) in dataList" :key="index">
			<view class="date">{{ dateTranfer(item.createTime) }}</view>
			<view class="item" @tap="navTo(`/pages/richangxuncha/xunchaxiangqing?id=${item.id}&name=${item.taskName || item.patrolTitle}`)">
				<view class="flex justify-between align-center">
					<text class="name">{{ item.taskName || item.patrolTitle }}</text>
					<uni-icons type="forward" size="16" color="#597EF7"></uni-icons>
				</view>
				<view class="flex justify-between align-center">
					<view class="time">巡查时间 {{ timeTranfer(item.startTime) }}~{{ timeTranfer(item.endTime) }}</view>
					<view class="count flex align-center">
						<view class="icon icon2">已巡</view>
						<view class="num">{{ item.totalNum }}</view>
						<view class="icon icon1">正常</view>
						<view class="num text-blue">{{ item.normalNum }}</view>
						<view class="icon icon3">异常</view>
						<view class="num">{{ item.abnormalNum }}</view>
					</view>
				</view>
			</view>
		</view>
	</z-paging>
</template>

<script>
import { getPatrolRecordListApi } from '@/api/system/changxiao.js';
import moment from 'moment';
export default {
	mixins: [],
	data() {
		return {
			list: 20,
			pageNo: 1,
			pageSize: 10,
			dataList: []
		};
	},
	computed: {
		baseFontSize() {
			return this.$store.getters.fontSize;
		}
	},
	methods: {
		dateTranfer(date) {
			if (!date) {
				return '未知';
			}
			return moment(date).format('YYYY-MM-DD');
		},
		timeTranfer(date) {
			if (!date) {
				return '未知';
			}
			return moment(date).format('HH:mm:ss');
		},
		loadList(pageNo, pageSize) {
			// 调用接口获取列表数据
			getPatrolRecordListApi({
				pageNo: pageNo,
				pageSize: pageSize
			})
				.then(res => {
					this.$refs.paging.complete(res.data.list);
				})
				.catch(res => {
					this.$refs.paging.complete(false);
				});
		},
		downCallback() {
			// console.log(1)
			// this.mescroll.resetUpScroll();
			getPatrolRecordListApi({
				pageNo: this.pageNo,
				pageSize: this.pageSize
			}).then(res => {
				this.dataList = res.data.list;
			});
		},
		upCallback() {
			// this.getProductList();
		},
		navTo(path) {
			this.$tab.navigateTo(path);
		}
	}
};
</script>

<style lang="scss">
page {
	background: #f7f8f9;
}
</style>
<style lang="scss" scoped>
@import './index.scss';
</style>
